#include "OC.h"
#include "stats.h"
#include "main.h"
//#include <mc9s12dp512.h>     /* derivative information */
#include "derivative.h"
#include <hidef.h>
#include "sensor.h"

extern unsigned short lastHealth;

void oc0_init(void)
{
	TIOS |= 0x01;
	TIE |= 0x01;
	TSCR1 = 0x80;
	TSCR2 = 0x07;
	PACTL = 0;
	lastHealth = 100;
	TC0 = TCNT + WAITTIME;
}
                       
interrupt 8 void TOC0handler(void)
{
	TFLG1 = 0x01;
	mode = check_scanners();

	TC0 = TC0 + WAITTIME;
}

int check_scanners(void)
{
	unsigned short left = 0;
	unsigned short front = 0;
	unsigned short right = 0;
	unsigned short health = 0;
	
  set_sensor_angle(TEN);	
	get_scanner_stats(&left, &front, &right);
	health = get_health();
	PTP = 0x00;
	if(front<1000||right<1000||left<1000)
    return PURSUE;
	return FIND;
}

